﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Prodma.DataAccess.Models.UserControlViewModels.DataPagerVm>" %>
<% int limitValue = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["popupDataPagerLimit"]); %>
<% int pageCount = ViewData.Model.TotalRowCount / limitValue; %>

<% if (ViewData.Model.TotalRowCount <= limitValue)
   {
       return;
   } %>

<% if (ViewData.Model.TotalRowCount % limitValue > 0)
   {
       pageCount++;
   } %>
   
   <% string url = "/" + ViewData.Model.View + "/index/?"; %>
   <% if (Request.QueryString["find"] == null) %>
   <% { %>
        <% if (ViewData.Model.Keys.Count != 0) %>
        <% { %>
             <% for (int i = 0; i < ViewData.Model.Keys.Count; i++) %>  
             <% { %>
                  <% url += ViewData.Model.Keys[i] + "=" + ViewData.Model.Values[i]; %>
                  <% if (i != ViewData.Model.Keys.Count - 1) %>
                  <%{ %>
                      <% url += "&"; %>
                  <%} %>
             <% } %>
             <input class="pageNumberBoxAjax" type="submit" value="&lt;&lt;&lt" onclick="$('.page').attr('value',0);;" />
             <% for (int j = 0; j < pageCount; j++) %>
             <% { %>
                    <input class="pageNumberBoxAjax" type="submit" value=<%=j+1 %> onclick="$('.page').attr('value',this.value-1);" />
             <% } %>
        <% } %>
   <% } %>
   <% else %>
   <% { %>
        <% if (ViewData.Model.Keys.Count != 0) %>
        <% { %>
             <% for (int i = 0; i < ViewData.Model.Keys.Count; i++) %>  
             <% { %>
                  <% url += ViewData.Model.Keys[i] + "=" + ViewData.Model.Values[i]; %>
                  <% if (i != ViewData.Model.Keys.Count - 1) %>
                  <%{ %>
                      <% url += "&"; %>
                  <%} %>
             <% } %>
             <% for (int j = 0; j < pageCount; j++) %>
             <% { %>
                    <input class="pageNumberBoxAjax" type="submit" value=<%=j+1 %> onclick="$('.page').attr('value',this.value-1);" />
             <% } %>
        <% } %>
        
   <% } %>
   
   <input class="pageNumberBoxAjax" type="submit" value=">>>" onclick="$('.page').attr('value',<%=pageCount-1 %>);" />
   <div class="pageContainerHeader">
    Sayfa <%=Convert.ToInt32(Request.QueryString["page"]) + 1%> / <%=pageCount%>
   </div>
   
   <input type="hidden" id="page" name="page" class="page" />